//
//  NSDate+Addtions.swift
//  DeliveryClerk
//
//  Created by autozi01 on 16/9/29.
//  Copyright © 2016年 autozi. All rights reserved.

//https://github.com/DrAma999/AFSwiftDateExtension/blob/master/NSDateExtension/AFDateSwiftExtension.swift

import UIKit

extension NSDate {
    
    // MARK: NSDate operators overload
}

/**
 Compare dates
 */
public  func <= (left: NSDate, right: NSDate) -> Bool {
    let result = left.compare(right as Date)
    var isEarlier = false
    if (result == .orderedAscending || result == .orderedSame) {
        isEarlier = true
    }
    return isEarlier
}

public  func >=(left: NSDate, right: NSDate) -> Bool {
    let result = left.compare(right as Date)
    var isLater = false
    if (result == .orderedDescending || result == .orderedSame) {
        isLater = true
    }
    return isLater
}
public  func >(left: NSDate, right: NSDate) -> Bool {
    let result = left.compare(right as Date)
    var isLater = false
    if (result == .orderedDescending) {
        isLater = true
    }
    return isLater
}
public  func <(left: NSDate, right: NSDate) -> Bool {
    let result = left.compare(right as Date)
    var isEarlier = false
    if (result == .orderedAscending) {
        isEarlier = true
    }
    return isEarlier
}
public func ==(left: NSDate, right: NSDate) -> Bool {
    let result = left.compare(right as Date)
    var isEqual = false
    if (result == .orderedSame) {
        isEqual = true
    }
    return isEqual
    
}
